package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.HorizontalScrollView;
import o.cjy;
import o.cjy.d;
import o.dky$o;
import o.Logger;
import o.MinimumFactory;

public class BounceHorizontalScrollView extends HorizontalScrollView implements d {
    private static final String ˏ = BounceHorizontalScrollView.class.getSimpleName();
    private float ʻ;
    private float ʼ;
    protected boolean ˊ = false;
    protected cjy ˋ = null;
    protected boolean ˎ = true;
    protected boolean ॱ = false;
    private float ॱॱ;
    private float ᐝ;

    public BounceHorizontalScrollView(Context context) {
        super(context);
        ˏ(null);
    }

    public BounceHorizontalScrollView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˏ(attributeSet);
    }

    public BounceHorizontalScrollView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˏ(attributeSet);
    }

    private void ˏ(AttributeSet attributeSet) {
        if (attributeSet != null) {
            TypedArray typedArray = null;
            try {
                typedArray = getContext().obtainStyledAttributes(attributeSet, dky$o.ʻʽ);
                this.ˊ = typedArray.getBoolean(dky$o.ʻʻ, false);
                this.ॱ = typedArray.getBoolean(dky$o.ʻʼ, false);
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Exception e) {
                Logger.e(ˏ, "init(AttributeSet attrs) " + e.toString());
                if (typedArray != null) {
                    typedArray.recycle();
                }
            } catch (Throwable th) {
                if (typedArray != null) {
                    typedArray.recycle();
                }
            }
        }
        if (this.ˊ) {
            this.ˋ = new cjy(this);
        }
    }

    public boolean onInterceptTouchEvent(MotionEvent motionEvent) {
        boolean z = false;
        if (this.ˊ && this.ˋ != null && this.ˋ.ˋ(motionEvent)) {
            return true;
        }
        if (this.ˎ && !ˏ(motionEvent)) {
            return z;
        }
        try {
            return super.onInterceptTouchEvent(motionEvent);
        } catch (IllegalArgumentException e) {
            return z;
        }
    }

    private boolean ˏ(MotionEvent motionEvent) {
        switch (motionEvent.getAction()) {
            case 0:
                this.ʼ = 0.0f;
                this.ॱॱ = 0.0f;
                this.ʻ = motionEvent.getX();
                this.ᐝ = motionEvent.getY();
                break;
            case 2:
                float x = motionEvent.getX();
                float y = motionEvent.getY();
                this.ॱॱ += Math.abs(x - this.ʻ);
                this.ʼ += Math.abs(y - this.ᐝ);
                if (this.ॱ) {
                    if (MinimumFactory.getBoolValue(getContext()) && x - this.ʻ > 0.0f && ˌ()) {
                        this.ʻ = x;
                        this.ᐝ = y;
                        return false;
                    } else if (x - this.ʻ < 0.0f && ˋˋ()) {
                        this.ʻ = x;
                        this.ᐝ = y;
                        return false;
                    }
                }
                this.ʻ = x;
                this.ᐝ = y;
                if (this.ॱॱ - this.ʼ > 5.0f) {
                    getParent().requestDisallowInterceptTouchEvent(true);
                    break;
                }
                break;
        }
        return true;
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        if (this.ˊ && this.ˋ != null && this.ˋ.ˏ(motionEvent)) {
            return true;
        }
        try {
            return super.onTouchEvent(motionEvent);
        } catch (IllegalArgumentException e) {
            return false;
        }
    }

    public boolean ˌ() {
        return getScrollX() == 0;
    }

    public boolean ˋˋ() {
        int measuredWidth = getChildAt(0).getMeasuredWidth();
        int width = getWidth();
        if (measuredWidth > width && getScrollX() != measuredWidth - width) {
            return false;
        }
        return true;
    }

    public boolean ˎˎ() {
        return false;
    }

    public boolean ˋᐝ() {
        return false;
    }
}
